<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The LuaSandbox class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="luasandbox.examples-basic.html">« Basic usage for LuaSandbox</a></li>
      <li style="float: right;"><a href="luasandbox.callfunction.html">LuaSandbox::callFunction »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.luasandbox.html">LuaSandbox</a></li>
    <li>The LuaSandbox class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.luasandbox" class="reference">

 <h1 class="title">The LuaSandbox class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL luasandbox &gt;= 1.0.0)</p>


  <div class="section" id="luasandbox.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    The LuaSandbox class creates a Lua environment and allows for execution of
    Lua code.
   </p>
  </div>


  <div class="section" id="luasandbox.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">LuaSandbox</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.luasandbox.html#luasandbox.constants.samples"><var class="varname">SAMPLES</var></a></var><span class="initializer"> = 0</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.luasandbox.html#luasandbox.constants.seconds"><var class="varname">SECONDS</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.luasandbox.html#luasandbox.constants.percent"><var class="varname">PERCENT</var></a></var><span class="initializer"> = 2</span>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="luasandbox.callfunction.html" class="methodname">callFunction</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">...$args</code></span>): <span class="type"><span class="type">array</span>|<span class="type">bool</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.disableprofiler.html" class="methodname">disableProfiler</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.enableprofiler.html" class="methodname">enableProfiler</a></span>(<span class="methodparam"><span class="type">float</span> <code class="parameter">$period</code><span class="initializer"> = 0.02</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.getcpuusage.html" class="methodname">getCPUUsage</a></span>(): <span class="type">float</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.getmemoryusage.html" class="methodname">getMemoryUsage</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.getpeakmemoryusage.html" class="methodname">getPeakMemoryUsage</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.getprofilerfunctionreport.html" class="methodname">getProfilerFunctionReport</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$units</code><span class="initializer"> = LuaSandbox::SECONDS</span></span>): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="luasandbox.getversioninfo.html" class="methodname">getVersionInfo</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.loadbinary.html" class="methodname">loadBinary</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$code</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$chunkName</code><span class="initializer"> = &#039;&#039;</span></span>): <span class="type"><a href="class.luasandboxfunction.html" class="type LuaSandboxFunction">LuaSandboxFunction</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.loadstring.html" class="methodname">loadString</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$code</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$chunkName</code><span class="initializer"> = &#039;&#039;</span></span>): <span class="type"><a href="class.luasandboxfunction.html" class="type LuaSandboxFunction">LuaSandboxFunction</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.pauseusagetimer.html" class="methodname">pauseUsageTimer</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.registerlibrary.html" class="methodname">registerLibrary</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$libname</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$functions</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.setcpulimit.html" class="methodname">setCPULimit</a></span>(<span class="methodparam"><span class="type"><span class="type">float</span>|<span class="type">bool</span></span> <code class="parameter">$limit</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.setmemorylimit.html" class="methodname">setMemoryLimit</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$limit</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.unpauseusagetimer.html" class="methodname">unpauseUsageTimer</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="luasandbox.wrapphpfunction.html" class="methodname">wrapPhpFunction</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$function</code></span>): <span class="type"><a href="class.luasandboxfunction.html" class="type LuaSandboxFunction">LuaSandboxFunction</a></span></div>

   }</div>


  </div>


  <div class="section" id="luasandbox.constants">
   <h2 class="title">预定义常量</h2>
   <dl>

    
     <dt id="luasandbox.constants.samples"><strong><code>LuaSandbox::SAMPLES</code></strong></dt>

     <dd>

      <p class="para">
       Used with <span class="methodname"><a href="luasandbox.getprofilerfunctionreport.html" class="methodname">LuaSandbox::getProfilerFunctionReport()</a></span> to return timings in samples.
      </p>
     </dd>

    

    
     <dt id="luasandbox.constants.seconds"><strong><code>LuaSandbox::SECONDS</code></strong></dt>

     <dd>

      <p class="para">
       Used with <span class="methodname"><a href="luasandbox.getprofilerfunctionreport.html" class="methodname">LuaSandbox::getProfilerFunctionReport()</a></span> to return timings in seconds.
      </p>
     </dd>

    

    
     <dt id="luasandbox.constants.percent"><strong><code>LuaSandbox::PERCENT</code></strong></dt>

     <dd>

      <p class="para">
       Used with <span class="methodname"><a href="luasandbox.getprofilerfunctionreport.html" class="methodname">LuaSandbox::getProfilerFunctionReport()</a></span> to return timings in percentages of the total.
      </p>
     </dd>

    

   </dl>

  </div>



 </div>

 

















































































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="luasandbox.callfunction.html">LuaSandbox::callFunction</a> — Call a function in a Lua global variable</li><li><a href="luasandbox.disableprofiler.html">LuaSandbox::disableProfiler</a> — Disable the profiler</li><li><a href="luasandbox.enableprofiler.html">LuaSandbox::enableProfiler</a> — Enable the profiler.</li><li><a href="luasandbox.getcpuusage.html">LuaSandbox::getCPUUsage</a> — Fetch the current CPU time usage of the Lua environment</li><li><a href="luasandbox.getmemoryusage.html">LuaSandbox::getMemoryUsage</a> — Fetch the current memory usage of the Lua environment</li><li><a href="luasandbox.getpeakmemoryusage.html">LuaSandbox::getPeakMemoryUsage</a> — Fetch the peak memory usage of the Lua environment</li><li><a href="luasandbox.getprofilerfunctionreport.html">LuaSandbox::getProfilerFunctionReport</a> — Fetch profiler data</li><li><a href="luasandbox.getversioninfo.html">LuaSandbox::getVersionInfo</a> — Return the versions of LuaSandbox and Lua</li><li><a href="luasandbox.loadbinary.html">LuaSandbox::loadBinary</a> — Load a precompiled binary chunk into the Lua environment</li><li><a href="luasandbox.loadstring.html">LuaSandbox::loadString</a> — Load Lua code into the Lua environment</li><li><a href="luasandbox.pauseusagetimer.html">LuaSandbox::pauseUsageTimer</a> — Pause the CPU usage timer</li><li><a href="luasandbox.registerlibrary.html">LuaSandbox::registerLibrary</a> — Register a set of PHP functions as a Lua library</li><li><a href="luasandbox.setcpulimit.html">LuaSandbox::setCPULimit</a> — Set the CPU time limit for the Lua environment</li><li><a href="luasandbox.setmemorylimit.html">LuaSandbox::setMemoryLimit</a> — Set the memory limit for the Lua environment</li><li><a href="luasandbox.unpauseusagetimer.html">LuaSandbox::unpauseUsageTimer</a> — Unpause the timer paused by LuaSandbox::pauseUsageTimer</li><li><a href="luasandbox.wrapphpfunction.html">LuaSandbox::wrapPhpFunction</a> — Wrap a PHP callable in a LuaSandboxFunction</li></ul>
</div>
</div></div></body></html>